import {
  createStore
} from 'vuex'

import a from "vuex-persistedstate";  //安装cnpm install --save vuex-persistedstate

export default createStore({
  state: {
      userInfo: null,
      editableTabs:[],   //tag栏
      color:''
  },
  mutations: {
      setUserInfo(state, data) {
          state.userInfo = data
      },

      setSignOut(state) {
          state.userInfo = null
      },
    addTop(state,obj){
        state.editableTabs.push(obj)
    },
    remTop(state,obj){
        state.editableTabs = state.editableTabs.filter(item=>{
            return item.name != obj
        })
    },
  // 点击换肤
    addcolor(state,obj){
        state.color = obj
        console.log(state.color);
    }
  },
  getters: {
      
  },
  actions: {
      userInfos({
          commit
      }, data) {
          commit("setUserInfo", data)
      },

      signOuts({
          commit
      }) {
          commit("setSignOut")
      },

  },
  modules: {},
  plugins: [a()]
})
